<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "order_info_good".
 *
 * @property int $id
 * @property int $order_id 订单id
 * @property int $good_id 商品id
 * @property string $unit_price 商品单价
 * @property int $num 下单数量
 */
class OrderInfoGood extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'order_info_good';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['order_id', 'good_id', 'num'], 'integer'],
            [['unit_price'], 'number']
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'order_id' => 'Order ID',
            'good_id' => 'Good ID',
            'unit_price' => 'Unit Price',
            'num' => 'Num',
        ];
    }

    public function getOrder(){
      return $this->hasOne(OrderInfo::class, ['id' => 'order__id']);
    }

    public function getGood(){
      return $this->hasOne(Good::class, ['id' => 'good_id']);
    }
}
